﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace backupmanagement
{
    public class BackOperation
    {
        /// <summary>
        /// 获取特定文件路径
        /// </summary>
        /// <param name="currentPath">目标目录（这儿是数据库备份目录）</param>
        /// <param name="dt">日期（获取当天备份文件路径）</param>
        /// <returns></returns>
        public List<string> GetFilePath(string currentPath, DateTime dt)
        {
            var paths = Directory.GetFiles(currentPath);
            FileInfo fi = null;
            List<string> filePaths = new List<string>();
            foreach (var path in paths)
            {
                fi = new FileInfo(path);
                if (fi.CreationTime.Day != dt.Day)
                {
                    fi = null;
                    continue;
                }
                else
                {
                    filePaths.Add(path);
                }
            }
            return filePaths;
        }

        //移动并压缩指定的文件
        public void MoveAndZip(string filePath, string target, string passWord)
        {
            ZipHelper.ZipFile(filePath, target , passWord);
        }
    }
}
